<template>
  <view class="disease-detail">
    <!-- 基本信息 -->
    <view class="info-card">
      <text class="name">{{ disease.name }}</text>
      <text class="department">{{ disease.department }}</text>
      <view class="tags">
        <text 
          v-for="(tag, index) in disease.tags"
          :key="index"
        >{{ tag }}</text>
      </view>
    </view>
    
    <!-- 疾病介绍 -->
    <view class="section-card">
      <view class="section-title">疾病介绍</view>
      <text class="content">{{ disease.introduction }}</text>
    </view>
    
    <!-- 病因 -->
    <view class="section-card">
      <view class="section-title">病因</view>
      <view class="cause-list">
        <view 
          class="cause-item"
          v-for="(item, index) in disease.causes"
          :key="index"
        >
          <text class="dot"></text>
          <text class="content">{{ item }}</text>
        </view>
      </view>
    </view>
    
    <!-- 症状表现 -->
    <view class="section-card">
      <view class="section-title">症状表现</view>
      <view class="symptom-list">
        <view 
          class="symptom-item"
          v-for="(item, index) in disease.symptoms"
          :key="index"
        >
          <text class="dot"></text>
          <text class="content">{{ item }}</text>
        </view>
      </view>
    </view>
    
    <!-- 治疗方案 -->
    <view class="section-card">
      <view class="section-title">治疗方案</view>
      <text class="content">{{ disease.treatment }}</text>
    </view>
    
    <!-- 注意事项 -->
    <view class="section-card">
      <view class="section-title">注意事项</view>
      <view class="notice-list">
        <view 
          class="notice-item"
          v-for="(item, index) in disease.notices"
          :key="index"
        >
          <text class="dot"></text>
          <text class="content">{{ item }}</text>
        </view>
      </view>
    </view>
    
    <!-- 相关医生 -->
    <view class="section-card">
      <view class="section-header">
        <text class="title">相关医生</text>
        <text class="more">查看全部</text>
      </view>
      <scroll-view 
        scroll-x 
        class="doctor-list"
        :show-scrollbar="false"
      >
        <view 
          class="doctor-item"
          v-for="(item, index) in disease.doctors"
          :key="index"
          @tap="viewDoctor(item)"
        >
          <image :src="item.avatar" mode="aspectFill" class="avatar" />
          <text class="name">{{ item.name }}</text>
          <text class="title">{{ item.title }}</text>
        </view>
      </scroll-view>
    </view>
    
    <!-- 底部按钮 -->
    <view class="bottom-bar">
      <button class="action-btn outline" @tap="showConsult">在线咨询</button>
      <button class="action-btn primary" @tap="makeAppointment">立即预约</button>
    </view>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue'

// 疾病信息
const disease = ref({
  id: 1,
  name: '冠心病',
  department: '心内科',
  tags: ['常见病', '慢性病', '心血管疾病'],
  introduction: '冠心病是指冠状动脉血管发生动脉粥样硬化病变而引起血管腔狭窄或阻塞，导致心肌缺血、缺氧或坏死而引起的心脏病。',
  causes: [
    '高血压、高血脂、糖尿病等基础疾病',
    '吸烟、饮酒等不良生活习惯',
    '精神压力过大',
    '年龄、性别、遗传因素等'
  ],
  symptoms: [
    '胸痛、胸闷',
    '心悸、气短',
    '乏力、疲劳',
    '出汗、恶心'
  ],
  treatment: '冠心病的治疗包括药物治疗、介入治疗和手术治疗。药物治疗主要包括抗血小板、他汀类调脂、β受体阻滞剂等；介入治疗主要是冠状动脉支架植入术；手术治疗主要是冠状动脉搭桥术。',
  notices: [
    '保持良好的生活习惯，戒烟限酒',
    '合理饮食，控制高盐高脂饮食',
    '适量运动，避免剧烈运动',
    '保持心情愉快，避免情绪波动'
  ],
  doctors: [
    {
      id: 1,
      name: '张医生',
      title: '主任医师',
      avatar: '/static/doctor/avatar1.jpg'
    },
    {
      id: 2,
      name: '李医生',
      title: '副主任医师',
      avatar: '/static/doctor/avatar2.jpg'
    }
  ]
})

// 查看医生详情
const viewDoctor = (doctor) => {
  uni.navigateTo({
    url: `/pages/doctor/detail?id=${doctor.id}`
  })
}

// 在线咨询
const showConsult = () => {
  uni.showModal({
    title: '提示',
    content: '是否开始在线咨询？',
    success: (res) => {
      if (res.confirm) {
        // 这里处理在线咨询逻辑
      }
    }
  })
}

// 立即预约
const makeAppointment = () => {
  uni.navigateTo({
    url: `/pages/appointment/department?disease=${disease.value.name}`
  })
}

onMounted(() => {
  const pages = getCurrentPages()
  const page = pages[pages.length - 1]
  const { id } = page.$page?.options || {}
  
  // 这里根据ID加载疾病详情
  console.log('加载疾病详情:', id)
})
</script>

<style lang="scss">
.disease-detail {
  min-height: 100vh;
  background: $bg-color;
  padding-bottom: 120rpx;
  
  .info-card {
    background: #fff;
    padding: 30rpx;
    margin-bottom: 20rpx;
    
    .name {
      font-size: 36rpx;
      color: $text-primary;
      font-weight: bold;
      margin-bottom: 12rpx;
      display: block;
    }
    
    .department {
      font-size: 28rpx;
      color: $text-regular;
      margin-bottom: 16rpx;
      display: block;
    }
    
    .tags {
      text {
        display: inline-block;
        font-size: 24rpx;
        color: $primary-color;
        background: $primary-light;
        padding: 4rpx 16rpx;
        border-radius: $radius-sm;
        margin-right: 16rpx;
      }
    }
  }
  
  .section-card {
    background: #fff;
    padding: 30rpx;
    margin-bottom: 20rpx;
    
    .section-title {
      font-size: 32rpx;
      color: $text-primary;
      font-weight: bold;
      margin-bottom: 20rpx;
    }
    
    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20rpx;
      
      .title {
        font-size: 32rpx;
        color: $text-primary;
        font-weight: bold;
      }
      
      .more {
        font-size: 28rpx;
        color: $text-secondary;
      }
    }
    
    .content {
      font-size: 28rpx;
      color: $text-regular;
      line-height: 1.6;
    }
    
    .cause-list,
    .symptom-list,
    .notice-list {
      .cause-item,
      .symptom-item,
      .notice-item {
        display: flex;
        align-items: flex-start;
        margin-bottom: 16rpx;
        
        &:last-child {
          margin-bottom: 0;
        }
        
        .dot {
          width: 12rpx;
          height: 12rpx;
          background: $primary-color;
          border-radius: 50%;
          margin-top: 12rpx;
          margin-right: 12rpx;
          flex-shrink: 0;
        }
        
        .content {
          flex: 1;
          font-size: 28rpx;
          color: $text-regular;
          line-height: 1.6;
        }
      }
    }
    
    .doctor-list {
      white-space: nowrap;
      
      .doctor-item {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        width: 160rpx;
        margin-right: 30rpx;
        
        .avatar {
          width: 120rpx;
          height: 120rpx;
          border-radius: 50%;
          margin-bottom: 12rpx;
        }
        
        .name {
          font-size: 28rpx;
          color: $text-primary;
          margin-bottom: 4rpx;
        }
        
        .title {
          font-size: 24rpx;
          color: $text-secondary;
        }
      }
    }
  }
  
  .bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20rpx 30rpx;
    background: #fff;
    box-shadow: $shadow-lg;
    display: flex;
    gap: 20rpx;
    
    .action-btn {
      flex: 1;
      height: 88rpx;
      line-height: 88rpx;
      font-size: 30rpx;
      border-radius: $radius-xl;
      
      &.outline {
        color: $primary-color;
        background: #fff;
        border: 2rpx solid $primary-color;
      }
      
      &.primary {
        color: #fff;
        background: $primary-gradient;
      }
      
      &:active {
        transform: scale(0.98);
      }
    }
  }
}
</style> 